package com.wwl.springcloud.controller;

import cn.hutool.core.util.IdUtil;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.wwl.springcloud.service.PaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wwl
 * @version 1.0
 * @date 2021/8/10 18:26
 * @description:
 */
@RestController
@Slf4j
@Api(value = "/payment", description = "Hystrix测试", tags = {"payment"})
public class PaymentController {
    @Autowired
    private PaymentService paymentService;
    @Value("${server.port}")
    private String serverPort;

    @ApiOperation("paymentInfo_OK")
    @PostMapping("/payment/hystrix/ok")
    public String paymentInfo_OK(@ApiParam(value = "id") @RequestParam(value = "id", required = false) Integer id) {
        String result = paymentService.paymentInfo_ok(id);
        log.info("*******result:" + result);
        return result;
    }

    @ApiOperation("paymentInfo_TimeOut")
    @PostMapping("/payment/hystrix/timeout")
    public String paymentInfo_TimeOut(@ApiParam(value = "id") @RequestParam(value = "id", required = false) Integer id) {
        String result = paymentService.paymentInfo_TimeOut(id);
        log.info("*******result:" + result);
        return result;
    }


}
